#include <iostream>
#include <atomic>
#include <thread>
#include <vector>
#include <unistd.h>

std::atomic<int> a(0);
std::atomic<int> b(0);

int ValueSet()
{
    int t = 1;
    a.store(t, std::memory_order_release);
    b.store(2, std::memory_order_release);
    return 0;
}

int Oberserver()
{
    int _a = a.load(std::memory_order_acquire);
    int _b = b.load(std::memory_order_acquire);
    if (_a == 0 &&  _b== 2)
    {
        std::cout << "a:" << _a << "; b:" << _b << std::endl;
        return -1;
    }
    return 0;
}

int main()
{
    while (1)
    {
        a = 0;
        b = 0;
        std::thread t1(ValueSet);
        std::thread t2(Oberserver);
        t1.join();
        t2.join();
    }

    // std::cout << "a:" << a << "; b:" << b << std::endl;
    return 0;
}
